package com.dysoft.flesh;

import com.dysoft.bones.DataManager;

/**
 * @author Sean Micklethwaite
 *         Aug 16, 2010 8:38:33 PM
 */
public class RendererDecorator implements Renderer {
	final RenderComponent decorator;
	final Renderer renderer;

	public RendererDecorator(RenderComponent decorator, Renderer renderer) {
		this.decorator = decorator;
		this.renderer = renderer;
	}

	public void render(RenderContext ctx) throws DataManager.DataObject.NotPresentException {
		decorator.activate(ctx);
		try {
			renderer.render(ctx);
		} finally {
			decorator.deactivate(ctx);
		}
	}

	@Override
	public String toString() {
		return decorator + ":" + renderer;
	}

	public RenderComponent getDecorator() {
		return decorator;
	}

	public Renderer getRenderer() {
		return renderer;
	}
}
